import {createSlice, PayloadAction} from "@reduxjs/toolkit";

//存储用户相关的信息



export type UserStateType={
    username:string,
    naLable:string
}


const InitUserState:UserStateType={
    username:'',
    naLable:'',
}

export const userSlice=createSlice({
    name:'user',  //这个是用户的状态管理
    initialState:InitUserState,
    reducers:{
        //动作
        loginRuder :(state:UserStateType,action:PayloadAction<UserStateType>)=>{
            return action.payload
        },
        logoutRuder:()=>{
            return InitUserState
        },
    }
})

export const {loginRuder,logoutRuder}=userSlice.actions
export default userSlice.reducer;